﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CommunityServerRest {
	public class Attachment {
		public byte[] Contents { get; set; }
		public string Filename { get; set; }
		public Attachment(String filename, Stream stream) {
			Filename = filename;
			Contents = new byte[stream.Length];
			stream.Read(Contents, 0, (int)stream.Length);
		}
		public Attachment(string path) {
			FileStream fs = new FileStream(path, FileMode.Open);
			Contents = new byte[fs.Length];
			fs.Read(Contents, 0, (int)fs.Length);
			Filename = Path.GetFileName(path);
			fs.Close();
		}
		public Attachment(string filename, byte[] contents) {
			Filename = filename;
			Contents = contents;
		}
			
	}
}
